home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / FIX_DESK / SOURCE / APPLICAT.C next >
C/C++ Source or Header  |  1988-09-07  |  1KB  |  64 lines

  1. #include <MacTypes.h>
  2.  
  3. #include "fix.h"
  4.  
  5. typedef struct appl_entry {
  6.     long appl_type;
  7.     long appl_directory;
  8.     unsigned char appl_name[NAME_SIZE];
  9. } appl_entry, *appl_ptr;
  10.  
  11. Handle appl_list;
  12.  
  13.     /* Perform initial application list processing. */
  14.  
  15. void pre_appl_processing()
  16. {
  17.     if (is_hfs) {
  18.         appl_count = 0;
  19.         appl_list = NewHandle(0L);    /* Clear application list... */
  20.     }
  21. }
  22.  
  23.     /* Perform final application list processing. */
  24.  
  25. void post_appl_processing()
  26. {
  27. #ifndef TEST_MODE
  28.  
  29.     unsigned char temp;
  30.  
  31.     if (is_hfs) {
  32.         kill_resource('APPL',0);    /* Kill existing application list. */
  33.         temp = '\0';
  34.         AddResource(appl_list, 'APPL', 0, &temp);
  35.         WriteResource(appl_list);
  36.         ReleaseResource(appl_list);
  37.     }
  38. #else TEST_MODE
  39.     DisposHandle(appl_list);
  40. #endif TEST_MODE
  41. }
  42.  
  43.     /* Add a new application entry. */
  44.  
  45. void add_application(type, dir_id, name)
  46.     long type;
  47.     int dir_id;
  48.     unsigned char *name;
  49. {
  50.     register appl_ptr blob;
  51.     register long size;
  52.  
  53.     appl_count++;
  54.     blob = (appl_ptr) NewPtr((long)sizeof(appl_entry));
  55.     blob->appl_type = type;
  56.     blob->appl_directory = dir_id;
  57.     copystr(blob->appl_name, name);
  58.     size = 9 + name[0];
  59.     if (size & 1)                    /* Keep word-aligned... */
  60.         size++;
  61.     PtrAndHand(blob, appl_list, size);
  62.     DisposPtr(blob);
  63. }
  64.